﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SummerTraining
{
    class Class
    {
        private List<Student> allStudents = new List<Student>();

        public void AddStudent(Student s)
        {
            if (NewComming != null)
            {
                StudentEventArgs arg = new StudentEventArgs();
                arg.Student = s;
                NewComming(this, arg);
            }
            allStudents.Add(s);

        }

        public int Count
        {
            get
            {
                return allStudents.Count;
            }
        }

        public event EventHandler NewComming;
    }

    public class Student
    { 
        public string Name { get; set; }
        public string Gender { get; set; }

        public Student(string name, string gender)
        {
            if (name == null || gender == null)
            {
                throw new NotWellFormattedException();
            }
            Name = name;
            Gender = gender;
        }
    }

    public class StudentEventArgs : EventArgs
    {
        public Student Student { get; set; }
    }

    public class NotWellFormattedException : Exception
    {

    }
}
